﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TierService;
using TierApplication;
using System.Data;
using DevExpress.Web.ASPxGridView;
using System.Web.Services;

public partial class System_admin_ProductList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindData();
        }
        else if (gridSearchResult.IsCallback && Page.IsPostBack)
        {
            System.Data.DataTable dt = (DataTable)ViewState["data"];
            gridSearchResult.DataSource = dt;
            gridSearchResult.DataBind();
        }
        
        
    }

    #region BindData
    private void BindData()
    {
        #region 权限检查
      
        #endregion

        //string SupplierName = this.txtKey.Text.Trim();
        //string field = this.DropField.SelectedValue;
        string strWhere = "";
        //if (SupplierName != "")
        //{
        //    strWhere += " and (" + field + " like'%" + SupplierName + "%')";
        //}

        T_SCHOOL mSCHOOL = new T_SCHOOL();
        DataSet ds = new DataSet();
        ds = mSCHOOL.GetList(strWhere);
        gridSearchResult.DataSource = ds.Tables[0];        
        gridSearchResult.DataBind();
        ViewState["data"] = ds.Tables[0];
    }
    #endregion

    #region btn_Search

    protected void btnQuery_Click(object sender, EventArgs e)
    {
        BindData();
    }

    protected void btnQuery_CallBack(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
    {
        BindData();
    }



    #endregion

    #region gridView事件
    protected void gridSearchResult_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
    {

        String theID = e.Keys[0].ToString();
        object theValues = this.gridSearchResult.GetRowValuesByKeyValue(theID, new String[] { "SCHOOLID" });
        String ProductID = theValues.ToString();
        if (!String.IsNullOrEmpty(ProductID))
        {
            T_SCHOOL mSchool = new T_SCHOOL();
            mSchool.Delete(ProductID);
        }
        e.Cancel = true;
        this.gridSearchResult.CancelEdit();
        BindData();
    }

    #endregion

}